﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.IO;
using System.Text;
using BUS;

public partial class Admin_LapBaoCao : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
            Response.Redirect("../Default.aspx");
        if (Boolean.Parse(Session["QuanLy"].ToString()) == false)
            Response.Redirect("../Default.aspx");
        if (!IsPostBack)
        {
            rptViewer.Visible = false;
        }
    }

    DateTime tungay;
    DateTime denngay;
    protected void btnNhapHang_Click(object sender, EventArgs e)
    {
        rptViewer.Visible = true;

        tungay = DateTime.Parse(dateTuNgay.SelectedDate.ToShortDateString());
        denngay = DateTime.Parse(dateDenNgay.SelectedDate.ToShortDateString());
        DataTable dt = ReportBUS.BaoCaoNhapHang(tungay, denngay);
        rpt.ReportDocument.SetDataSource(dt);
        rpt.ReportDocument.SetParameterValue("@tungay",tungay);
        rpt.ReportDocument.SetParameterValue("@denngay",denngay);
        rpt.DataBind();
        rptViewer.ReportSource = rpt;       
    }
    protected void btnXuatHang_Click(object sender, EventArgs e)
    {
        rptViewer.Visible = true;

        tungay = DateTime.Parse(dateTuNgay.SelectedDate.ToShortDateString());
        denngay = DateTime.Parse(dateDenNgay.SelectedDate.ToShortDateString());
        
        CrystalReportSource1.ReportDocument.SetDataSource(ReportBUS.BaoCaoXuatHang(tungay, denngay));
        CrystalReportSource1.ReportDocument.SetParameterValue("@tungay", tungay);
        CrystalReportSource1.ReportDocument.SetParameterValue("@denngay", denngay);
        CrystalReportSource1.DataBind();
        rptViewer.ReportSource = CrystalReportSource1;
    }
}
